const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    courseType: "",
    classHour: "",
    totalMoney: "",
    orderStatus: 2,
    odStatus: "待接单", 
    applyTime: '',
    openId: "sdhh444",
    dataId: null,
    studentId: '',
    teacherName: '',
    livel: '',
    platform: '',
    system: '',
    stuName: '',
  },

  // 改变订单状态
  changeOrderStatus() {
    let that = this;
    wx.request({
      url: "https://www.enjoyyz.com:8443/yinzuo/acceptOrder?orderid=" + that.data.dataId,
      method: 'PUT',
      // data: {
      //   orderid: that.data.dataId,
      // },
      success(res) {
        console.log(that.data.dataId)
        console.log(res)
        that.setData({
          odStatus: "已接单"
        })
      }
    })
    wx.navigateTo({
      url: '/pages/profileTab/mycourse/mycourse',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      dataId: options.dataId,
      openId: app.globalData.openid,
    })
    let that = this;
    wx.request({
      url: "https://www.enjoyyz.com:8443/yinzuo/mycourse",
      data: {
        openid: that.data.openId,
        status: that.data.orderStatus
      },
      success(res) {
        console.log(res.data,'res.data11')
        that.setData({
          // courseType: res.data[app.globalData.courseIndex].courseType,
          // classHour: res.data[app.globalData.courseIndex].classHour,
          // totalMoney: res.data[app.globalData.courseIndex].totalMoney


          courseType: res.data[app.globalData.courseIndex].courseType,
          classHour: res.data[app.globalData.courseIndex].classHour,
          totalMoney: res.data[app.globalData.courseIndex].totalMoney,
          studentId: res.data[app.globalData.courseIndex].name,
          teacherName: res.data[app.globalData.courseIndex].name,
          livel: res.data[app.globalData.courseIndex].level,
          platform: res.data[app.globalData.courseIndex].platform,
          system: res.data[app.globalData.courseIndex].system,
          stuName: res.data[app.globalData.courseIndex].stuName,
        })
        console.log(app.globalData.courseIndex,'app.globalData.courseIndex')
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})